<template>
  <div>
    <van-field v-model="text" :label="label" :type="type" :placeholder="placeholder" :rule="rule" />
  </div>
</template>

<script>
export default {
name: "LoginText",
  props:['label','type','placeholder','rule'],
  data(){
  return {
    text: ''
  }
  },
  methods:{
  handlerulg(){
    const rue= new RegExp(this.rule)
    if(rue.test(this.text)){
      this.$emit('inputChange',this.text)
    }else {
      this.$emit('inputChange','')
    }
  }
  },
  watch:{
  text(){
    this.handlerulg()
  }
  }
}
</script>

<style scoped>

</style>
